// Kony

#pragma once

#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "ActiveGameplayEffectHandle.h"
#include "WaitCooldownChange.generated.h"

class UAbilitySystemComponent;
struct FGameplayEffectSpec;

//多播委托
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCooldownChangeSignature, float, TimeRemaining);

/**
 * 等待冷却时间更变 异步任务
 * 用于给技能小组件设置技能冷却时 显示冷却时间和颜色改变等操作
 * meta = (ExposedAsyncProxy = AsyncTask) 用于蓝图调用异步任务 会在节点后面增加一个异步任务节点
 */
UCLASS(BlueprintType, meta = (ExposedAsyncProxy = AsyncTask))
class GASC_HUANLING_API UWaitCooldownChange : public UBlueprintAsyncActionBase
{
	GENERATED_BODY()
public:
	//冷却开始时触发
	UPROPERTY(BlueprintAssignable)
	FCooldownChangeSignature CooldownStart;
	//冷却结束时触发
	UPROPERTY(BlueprintAssignable)
	FCooldownChangeSignature CooldownEnd;
	//蓝图调用创建异步任务，仅供内部使用
	UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"))
	static UWaitCooldownChange* WaitForCooldownChange(UAbilitySystemComponent* AbilitySystemComponent, const FGameplayTag& InCooldownTag);

	//当小部件销毁时清理任务资源
	UFUNCTION(BlueprintCallable)
	void EndTask();

protected:
	UPROPERTY()
	TObjectPtr<UAbilitySystemComponent> ASC;
	
	FGameplayTag CooldownTag;

	//冷却时间标签更变时（也就是施加冷却时间，移除冷却时间标签时触发）
	void CooldownTagChanged(const FGameplayTag InCooldownTag, int32 NewCount);
	//激活能力回调函数
	void OnActiveEffectAdded(UAbilitySystemComponent* TargetASC, const FGameplayEffectSpec& SpecApplied, FActiveGameplayEffectHandle ActiveEffectHandle);
	
};
